from django.db import models
from django.utils.translation import ugettext_lazy as _
from django_model_utils.models import StatMixin, PageMixin


class Category(StatMixin, PageMixin, models.Model):
    '''
    This app creates categories to our webproject. They have a name and a slug
    and maybe a description, but this is optionally. All categories will get an
    absolute_url so we can display all entries in one category.
    '''
    name = models.CharField(verbose_name=_('Name'), max_length=150)
    slug = models.SlugField(max_length=150, unique=True)
    content = models.TextField(verbose_name=_('Beschreibung'))
    
    # ---
    # TODO: get all entries within one category
    # ----
    
    def __unicode__(self):
        return self.name
    
    @models.permalink
    def get_absolute_url(self):
        return 'category_detail', (), {'slug': self.slug}
    
    class Meta:
        verbose_name = _(u'Kategorie')
        verbose_name_plural = _(u'Kategorien')

